package com.wondream.myframework.app.common.mq.consumer;

import com.wondream.myframework.app.common.log.Log;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * consumeMode = ConsumeMode.ORDERLY 顺序消息
 */
@Slf4j
//@Component
//@RocketMQMessageListener(topic = "${rocketmq.demo.topic}", consumerGroup = "${rocketmq.consumer.group}")
public class DemoConsumer implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt messageExt) {
        log.info(Log.op("DemoConsumer.onMessage").kv("msgId", messageExt.getMsgId()).toString());
        String message = new String(messageExt.getBody(), StandardCharsets.UTF_8);

    }
}
